using System;

namespace Mbl.ParameterizedTest.FluentCollectionBuilding.Expectors.GeneralExpectations
{
    public class EqualityExpectation<T> : PredicateExpectation<T>
    {
        private readonly Func<T> _expected;

        public EqualityExpectation(T expected)
            : base(actual => Equals(actual, expected))
        {
            _expected = () => expected;
        }

        public EqualityExpectation(Func<T> expected)
            : base(actual => Equals(actual, expected()))
        {
            _expected = expected;
        }

        protected override string GetErrorMessage(T actual)
        {
            return $"Equality assertion failed. Expected <{_expected()}>. Actual <{actual}>.";            
        }        
    }
}